package com.tio.demo;


import org.tio.server.AioServer;
import org.tio.server.ServerGroupContext;
import org.tio.server.intf.ServerAioHandler;
import org.tio.server.intf.ServerAioListener;

import java.io.IOException;

/**
 * Author      : liyuemin
 * Time        : 2017/12/14 9:34
 * Description :
 */
public class HelloServerStarter {

    //handler,包括编码，解码，消息处理
    public static ServerAioHandler aioHandler = new HelloServerAioHandler();

    //事件监听
    public static ServerAioListener aioListener = null;

    //连接公用的上下文
    public static ServerGroupContext serverGroupContext = new ServerGroupContext(aioHandler,aioListener);

    public static AioServer aioserver = new AioServer(serverGroupContext);

    //需要绑定IP，不需要则null
    public static String serverIp = null;

    public static int serverPort = Const.PORT;

    //服务端启动程序入口
    public static void main(String [] args ) throws IOException{
        serverGroupContext.setHeartbeatTimeout(Const.TIMEOUT);
        aioserver.start(serverIp,serverPort);
    }

}
